package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.UUID;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FaEsmTaglog;
import com.ruoyi.system.service.IFaEsmTaglogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 鞋标签扫码记录Controller
 * 
 * @author colin
 * @date 2021-08-11
 */
@RestController
@RequestMapping("/system/taglog")
public class FaEsmTaglogController extends BaseController
{
    @Autowired
    private IFaEsmTaglogService faEsmTaglogService;

    /**
     * 查询鞋标签扫码记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:taglog:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaEsmTaglog faEsmTaglog)
    {
        startPage();
        List<FaEsmTaglog> list = faEsmTaglogService.selectFaEsmTaglogList(faEsmTaglog);
        return getDataTable(list);
    }

    /**
     * 导出鞋标签扫码记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:taglog:export')")
    @Log(title = "鞋标签扫码记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FaEsmTaglog faEsmTaglog)
    {
        List<FaEsmTaglog> list = faEsmTaglogService.selectFaEsmTaglogList(faEsmTaglog);
        ExcelUtil<FaEsmTaglog> util = new ExcelUtil<FaEsmTaglog>(FaEsmTaglog.class);
        return util.exportExcel(list, "鞋标签扫码记录数据");
    }

    /**
     * 获取鞋标签扫码记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:taglog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(faEsmTaglogService.selectFaEsmTaglogById(id));
    }

    /**
     * 新增鞋标签扫码记录
     */
    @PreAuthorize("@ss.hasPermi('system:taglog:add')")
    @Log(title = "鞋标签扫码记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaEsmTaglog faEsmTaglog)
    {
        String uuid = UUID.randomUUID().toString();
        faEsmTaglog.setId(uuid);
        return toAjax(faEsmTaglogService.insertFaEsmTaglog(faEsmTaglog));
    }

    /**
     * 修改鞋标签扫码记录
     */
    @PreAuthorize("@ss.hasPermi('system:taglog:edit')")
    @Log(title = "鞋标签扫码记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaEsmTaglog faEsmTaglog)
    {
        return toAjax(faEsmTaglogService.updateFaEsmTaglog(faEsmTaglog));
    }

    /**
     * 删除鞋标签扫码记录
     */
    @PreAuthorize("@ss.hasPermi('system:taglog:remove')")
    @Log(title = "鞋标签扫码记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(faEsmTaglogService.deleteFaEsmTaglogByIds(ids));
    }
}
